home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
DLGDSN41.ZIP
/
TCOLORTX.DOC
< prev
next >
Wrap
Text File
|
1992-11-16
|
3KB
|
90 lines
/*------------------------------------------------------------*/
/* filename - tcolortx.doc */
/* */
/* function(s) */
/* TColoredText member functions */
/*------------------------------------------------------------*/
/*----------------------------------------------------------------------
TColoredText is a descendent of TStaticText designed to allow the writing
of colored text when color monitors are used. With a monochrome or BW
monitor, TColoredText acts the same as TStaticText.
TColoredText is used in exactly the same way as TStaticText except that
the constructor has an extra ushort parameter specifying the attribute
desired. (Do not use a 0 attribute, black on black).
The source for TColoredText is listed below except for the draw method.
Since the draw method is 99% the same as that for TStaticText found in
Borland's Run Time Library source, I didn't feel that it was appropriate
for me copy it here. If you have the RTL you can reconstruct the draw
method since I do show the changes made.
----------------------------------------------------------------------*/
#define Uses_TColoredText
#define Uses_TStaticText
#define Uses_TApplication
#define Uses_TDrawBuffer
#define Uses_opstream
#define Uses_ipstream
#include <tv.h>
#include "tcolortx.h"
#if !defined( __CTYPE_H )
#include <ctype.h>
#endif // __CTYPE_H
#if !defined( __STRING_H )
#include <String.h>
#endif // __STRING_H
TColoredText::TColoredText( const TRect& bounds, const char *aText,
ushort attribute ) :
TStaticText( bounds, aText ),
attr( attribute )
{
}
ushort TColoredText::getTheColor()
{
if (TProgram::application->appPalette == apColor)
return attr;
else return getColor(1);
}
void TColoredText::draw()
Copy TStaticText.Draw from TSTATICT.CPP. Change the 6th line from
color = getColor(1);
to
color = getTheColor();
void TColoredText::write( opstream& os )
{
TStaticText::write( os );
os << attr;
}
void *TColoredText::read( ipstream& is )
{
TStaticText::read( is );
is >> attr;
return this;
}
TStreamable *TColoredText::build()
{
return new TColoredText( streamableInit );
}
TColoredText::TColoredText( StreamableInit ) : TStaticText( streamableInit )
{
}
const char * const near TColoredText::name = "TColoredText";